package demo02

import demo01.Student

/**
 * @author xiaoZhao
 * @date 2022/6/20
 * @describe 数据类型
 */
object Test06_DataType {
  def main(args: Array[String]): Unit = {
    // 1。整数类型
    val al: Byte = 127
    val a2: Byte = -128

    val a3 = 12

    val b1: Byte = 10
    val b2: Byte = (10 + 20)
    println(b2)

    val b3: Byte = (b1 + 10).toByte
    println(b3)

    // 2. 浮点类型
    val f1: Float = 1.232f
    val d2 = 12.987

    // 3.字符类型
    val c1 = 'a'
    val c2: Char = '9'
    println(s"${c1}+${c2}")

    val c3: Char = '\t'
    val c4: Char = '\n'

    // 4.布尔类型
    val isTrue = true
    val isFalse: Boolean = false
    println(isTrue)

    // 5.空类型
    def m1(): Unit = {
      println("m1被执行")
    }

    val a = m1();
    println(a)

    var student = new Student("lisi", 21)
    student = null
    println(student)

    def m2(n: Int): Int = {
      if (n == 0)
        throw new NullPointerException
      else
        return n
    }

    val b = m2(1)
    println(b)

  }
}
